function [f]=solveprice_importtax(beta1,P_jt,eX2beta2,Sc_jt,c,SM,Slocal,STC_idx,STF_idx,STF_rep,SN,mM)
%main input is price P which is vector JTx1
%span P from JTx1 to JCTx1
P_cjt=zeros(SN,1); P_cjt(STF_rep)=P_jt;
P_cjt=my_accumarray(STF_idx,P_cjt);
P_cjt(Slocal==0)=P_cjt(Slocal==0).*1.10; %regulated price
ed=exp(beta1*P_cjt).*eX2beta2; % exponential of delta
if sum(isinf(ed)) >0
   fprintf('pause since delta is inf');
    pause
end
sed=my_accumarray(STC_idx,ed); %sum of ed(j) within group TC
pr=ed./(1+sed); 
%pr is vector CTJx1
clear P_cjt ed sed
temp1=SM./mM.*pr;
temp2=temp1.*(1-pr).*beta1;
nume=my_accumarray(STF_idx,temp1);
deno=my_accumarray(STF_idx,temp2);
clear temp1 temp2
qjt=nume.*mM/100000; %total trash going to facility j at t
qjt=qjt(STF_rep);
mc=dcdq2(Sc_jt,c,qjt); %vector JTx1 since c_jt and q_jt are JTx1
f=P_jt-mc+nume(STF_rep)./deno(STF_rep);
end
